<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./vue.js"></script>
    <!-- 选项卡 [参考效果](https://www.jq22.com/yanshi24114) -->
    <style>
        .box {
            border: 1px solid #ececec;
            height: 300px;
            width: 300px;
        }

        .tab {
            width: 300px;
            height: 50px;
            display: flex;
            flex-direction: row;
            flex-wrap: nowrap;
            justify-content: space-around;
        }

        .main {
            width: 300px;
            height: 200px;
            text-align: center;
            line-height: 200px;
            font-size: 30px;
        }
    </style>
</head>

<body>
    <div id="app">
        <div class="box">
            <span class="tab">
                <button @click="add = 1" :class="{ active: add === 1 }">按钮一</button>
                <button @click="add = 2" :class="{ active: add === 2 }">按钮二</button>
                <button @click="add = 3" :class="{ active: add === 3 }">按钮三</button>
                <button @click="add = 4" :class="{ active: add === 4 }">按钮四</button>
            </span>
            <div class="main" v-if="add === 1">内容一</div>
            <div class="main" v-if="add === 2">内容二</div>
            <div class="main" v-if="add === 3">内容三</div>
            <div class="main" v-if="add === 4">内容四</div>
        </div>
    </div>
</body>
<script>
    const { createApp, ref } = Vue;

    createApp({
        setup() {
            const add = ref(0);

            return {
                add
            }
        }
    }).mount('#app')
</script>

</html>